<?php

namespace app\common\validate;

use think\Validate;

class Admin extends Validate
{

    /**
     * 验证规则
     */
    protected $rule = [
        'username' => 'require|regex:\w{3,30}|unique:admin',
        'nickname' => 'require',
        'mobile'   => 'regex:1[3-9]\d{9}|unique:admin,mobile',
        'password' => 'regex:\S{32}' 
    ];

    /**
     * 提示消息
     */
    protected $message = [
    ];

    /**
     * 字段描述
     */
    protected $field = [
    ];

    /**
     * 验证场景
     */
    protected $scene = [
    ];

    public function __construct(array $rules = [], $message = [], $field = [])
    {
        $this->field = [
            'username' => '用户名',
            'nickname' => '姓名',
            'mobile'   => '手机号',
            'password' => '密码'
        ];
        $this->message = array_merge($this->message, [
            'username.regex' => '请输入用户名',
        ]);
        parent::__construct($rules, $message, $field);
    }

}
